<template>
  <div>
    <el-form :model="loginInfoVo" label-width="100px" class="demo-ruleForm">
      <el-form-item label="用户名" prop="userId">
        <el-input type = "text" v-model="loginInfoVo.userId" placeholder="请输入用户名"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="userPassword">
        <el-input type="password" v-model="loginInfoVo.userPassword" placeholder="请输入密码"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="login">登录</el-button>
        <el-button @click="register">注册</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'FundLogin',
  data () {
    return {
      loginInfoVo: { userId: '', userPassword: '' },
      responseResult: []
    }
  },
  methods: {
    login () {
      this.$axios
        .post('/fund/user/login', {
          userId: this.loginInfoVo.userId,
          userPassword: this.loginInfoVo.userPassword
        })
        .then(successResponse => {
          // this.responseResult = JSON.stringify(successResponse.data)
          this.bizresponse = successResponse.data
          console.log(this.responseResult)
          if (successResponse.data.code === 0) {
            console.log(successResponse.data.data)
            sessionStorage.setItem('token', successResponse.data.data)
            this.$router.replace({path: '/fundlist'})
          } else {
            this.$message({
              type: 'error',
              message: this.bizresponse.message
            })
          }
        })
        .catch(failResponse => {})
    },
    register () {
      this.$router.replace({path: '/register'})
    }
  }
}
</script>

<style scoped>

</style>
